﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace LanAnh
{
    public partial class frmLoaiHang : Office2007Form
    {
        public frmLoaiHang()
        {
            InitializeComponent();
        }
         Data data = new Data();        
        public frmLoaiHang( string txt)
        {
            InitializeComponent();
            txtTen.Text = txt.ToString();
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTen.Text == "")
            {
                MessageBoxEx.Show("Nhập loại hàng !");
                txtTen.Focus();
            }            
            else
            {
                try
                {
                    string sql = "INSERT INTO tblLoaiHang(Ten) VALUES(N'" + txtTen.Text + "')";
                    data.executeNonQuery(sql);
                    this.Close();
                    frmSanPham sp = new frmSanPham();
                    sp.truyen(txtTen.Text);                    
                }
                catch
                {

                }
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
            frmSanPham sp = new frmSanPham();
            sp.truyen("");            
        }
        
        private void txtTen_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Down)
                btnThem.Focus();            
            if (e.KeyCode == Keys.Escape)
                this.Close();
        }
    }
}
